Skip to content

feat: altimate integrations command for GitHub, Jira and Linear - #1622

Open
hkaltai wants to merge 94 commits into
mainfrom
feat-local-integrations-sync
Open

hkaltai wants to merge 94 commits into
mainfrom
feat-local-integrations-sync

Conversation

@hkaltai

@hkaltai hkaltai commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

No linked issue. Stacked on #1609. The Claude Code plugin side is AltimateAI/altimate-claude-plugin#12.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds altimate integrations so GitHub, Jira and Linear can be connected from the terminal, using the same credential fields as the Altimate workspace web form, instead of setting them up in the web app. Stacked on #1609.

  • Detection: finds credentials already on the machine: gh's github.com login, jira-cli, JIRA_API_TOKEN, LINEAR_API_KEY, and MCP servers in Claude Code's config (GitHub's only in one of GitHub's official setups). A project .mcp.json only shows that a provider is present; its values are never used, and a Jira site and token must come from the same source.
  • fields <provider>: the form fields from the workspace's integrations catalog. They are cached, with a built-in fallback, and pre-filled from the machine. Secrets are reported only as a masked tail.
  • set / set-secret --from-clipboard | --from-env | --stdin: fills fields. A secret is read by the CLI itself and never printed.
  • connect <provider> [--local-only] [--share]: validates directly with GitHub, Jira or Linear, then either keeps the credential in the OS keychain or saves it as a connection in the user's own account and attaches it to the linked workspace. A rejected credential shows the provider's message and stores nothing.
  • Sharing needs --share: attaching to a workspace that is not private (or doesn't say) lets its members use the connection, so connect, update and sync only do it with --share. Without it nothing is written to the workspace, the connection stays in the user's account, and the result names altimate integrations sync <provider> --share. The check uses the workspace as read right before writing. A connection the workspace already uses stays attached, unless the write would promote it from a secondary connection to the entry's default. A connection that is already shared (its own privacy is not private, or missing) is not rewritten in place without --share either: the refusal comes before any write and names update <provider> --share or sync <provider> --share. Output says (private) only when neither the workspace nor the connection is shared, otherwise who can use it, also on a failure after a shared rewrite, and --json carries shared: true.
  • update <provider>: replaces a rejected token on the same connection.
  • status: reports rejected when a token stopped working.
  • Other commands: open-token-page, sync, block/unblock, disconnect (removes the local copy and the workspace connection this tool made).
  • Local vs synced:
    • A synced credential lives only in the workspace connection this tool made, and a local one lives only on this machine.
    • connect --local-only (Keep local) moves a workspace copy here and stays local until unblock.
    • block refuses a synced connection.
  • A rejected credential stores nothing:
    • Drafts are discarded.
    • A connection the workspace marks invalid is removed.
    • Local secrets are deleted only after the workspace accepts the upload.
  • Concurrency:
    • Writes go through the repo's Flock lock, as temp file plus rename. The state file and the secrets file (outside macOS) are mode 0600. The catalog cache and the mock-remote file hold no secrets and use the default mode.
    • Every decision and upload runs under one lock.
    • Secrets never go on argv; macOS security -i reads them from stdin.
  • Signed out: sync is skipped and no demo workspace is shown. status reports workspace.signedIn.
  • Output: every command has --json, which the Claude Code plugin reads.
  • No browser flow: there is no OAuth flow. Credentials come from the machine or are pasted into the same fields the web form uses.

Known limitations and follow-ups

  • Linux and Windows: a kept-local secret goes to a 0600 file, not an OS keychain. Spec AC5 asks for the keychain only; this needs libsecret and DPAPI support.

  • Connection identity: a managed connection is matched by its name, Provider (from <hostname>), not a source.machine field. Renaming the host orphans it, and fixing that needs a backend field. Keychain keys are not yet namespaced per Altimate tenant. Two machines with the same hostname also share one connection.

  • Org policy "local only": not built. The backend has no policy source yet.

  • Workspace integrations list: the backend only replaces the whole list (PATCH /datamates/{id}). The CLI re-reads it just before writing, but two concurrent writers can still race until there is an incremental or conditional update.

  • Values starting with -: integrations set can't take one, because the argument parser reads it as a flag.

  • Token expiry: shown for GitHub only. Jira and Linear don't report it.

  • After a failed workspace removal: when Keep local can't remove the workspace copy, the credential is kept here and a warning says so, but status doesn't yet show both copies coherently.

  • Rollback: restoring the previous secrets after a failed keychain write is best effort. A failed restore is not reported.

  • Secret-name fallback: treating catalog fields with known secret names as secret applies only to freshly fetched catalogs, not to a cached one.

  • Privacy re-check race: nothing ties the integrations PATCH to the privacy just read. If the workspace becomes public between that read and the write, the connection is widened and the result still says private. The exposure equals the normal order (a privacy change widens every default connection); only the report is stale. A real fix needs a conditional write in the backend.

  • Delete promotes a secondary: disconnect and Keep local delete the managed connection through the backend's delete rule, the same one the web app uses: if a shared workspace's entry also enables another of the owner's connections, the lowest remaining one becomes the default and is widened to the workspace's audience. The owner enabled that connection in that shared workspace, which is why attaching one there as a secondary already needs --share. A warning naming the promoted connection is a follow-up.

  • GitHub sources: only github.com is supported; GitHub Enterprise Server is a follow-up. A GitHub token is validated against api.github.com, so it is read only from a source that is for github.com: gh's own stored github.com login (gh runs without GH_TOKEN, GITHUB_TOKEN, GH_HOST and the enterprise token variables, with --hostname github.com), GitHub's official MCP setups word for word (docker with GitHub's image, npx @modelcontextprotocol/server-github, the github-mcp-server binary) where no host setting in the server, the shell or any Claude Code settings file names another host, or a token entered here. The shell's GITHUB_TOKEN/GH_TOKEN are not read: they can hold a token for any host. A token found only there, or in an unofficial MCP setup, is entered once with connect github.

  • Another Altimate sign-in: a connection id is recorded with the backend it belongs to. While the recorded workspace copy is on another sign-in, connect, update, sync, Keep local and disconnect refuse and change nothing, and status says where it is.

  • Secondary-only attach: appending this connection as a secondary to a shared workspace's entry is refused without --share, and reported as shared with it, although the backend widens only defaults. Kept conservative: deleting the default later promotes and widens it.

  • Plugin: the Claude Code plugin has no --share control yet. On a shared workspace, its Link workspace and Sync all show the refusal reason.

  • Lock and slow backends: a command holds the local lock across its workspace calls (20 s timeout each), while another command waiting for the lock gives up after 30 s. Only a slow backend hits this.

  • Review follow-ups (minor, deferred): a typed Jira site can be paired with a detected token from another source; acli and the Linear CLI are shown as syncable though no credential is read from them; only ~/.config/.jira/.config.yml is read for jira-cli; Keep local with an unreachable provider replaces a valid workspace copy with an unverified one; a 4xx meaning bad input is classed as unreachable; a local record whose workspace update was marked invalid is not tracked; status judges a kept-local credential by whichever connection is shown; detach doesn't treat an unknown link the way attach does; a keychain write isn't read back; request abort and malformed-body handling and the real clipboard/stdin adapters have no checked-in tests.

  • Outside this PR (pre-existing, noted for follow-up): workspace/resend-hint.ts does not shell-quote skill names; native/dbt/project-lineage.ts parses a column like from1 as the keyword from.

  • Partial-failure edge cases: if sync can't remove a legacy local key after an upload, re-running sync doesn't retry that one key. In text mode, the cleanup warning is hidden when the workspace attach fails at the same time.

  • Env overrides: ALTIMATE_INTEGRATIONS_* backend and API variables (and JIRA_BASE_URL pairing) are honoured in every build. Tests and the local-backend setup rely on them; they should only apply under mock mode or in test builds.

  • Stale connection ids: attach replaces an entry whose connection id is missing from every connection the user can see. Telling a deleted connection from one the user can't see needs a backend rule.

  • Draft secret names: drafts are not recorded by field name, so a draft for a field the workspace catalog later drops is not found by discard or disconnect.

  • Unreadable login on disconnect: for a record that isn't synced, the workspace step is skipped, so a copy that exists only in the workspace is left in place.

  • Signed-out disconnect after a failed Keep local removal: it reports success while the workspace copy remains.

  • Draft writes: a field typed with set while a connect is being checked isn't part of the credential comparison; only the stored credential is.

  • Plugin: the pane doesn't yet show workspaceUnchecked (a failed workspace lookup in status), so counts can look synced when the workspace wasn't read.

Pre-existing issues seen during review, in code from #1609 (not changed here):

  • api/client.ts signOut: a failed withdrawClaudeSkills is swallowed, with no warning or retry.
  • cli/cmd/link.ts: picking the workspace that's already linked returns before the --claude-md write, and a failed CLAUDE.md write is swallowed by an empty catch.
  • mcp-server/adapter.ts: tables beyond MAX_FUSED_TABLES are dropped silently.
  • tool-cli/workspace-tools.ts: projectIsLinked ignores ALTIMATE_DISABLE_WORKSPACE.
  • tool-cli/claude-md.ts: there's a window between the lstat check and the CLAUDE.md write.
  • cli/cmd/tool.ts: the connections stamp uses only mtime and size.
  • tools/sql-result-format.ts: csvCell doesn't neutralise =, +, - and @ prefixes.
  • workspace/client.ts: setup reads credentials before the disabled check.
  • session/analyst-effort.ts: an unknown explicit variant skips the analyst default.

How did you verify your code works?

  • bun test test/altimate/integrations.test.ts: 238 pass, 0 fail. Every test case is listed below.
  • bun test test/altimate: 11,692 pass, 1 fail (an unrelated review.test.ts timing case that passes alone). tsgo --noEmit (the package typecheck) is clean.
  • CI is green on the latest commit.
  • Ran against a local Altimate backend with real GitHub and Jira credentials:
    • GitHub kept local, validated against api.github.com with nothing sent to Altimate
    • Jira validated and synced
    • a bad Linear key rejected with Linear's 401
    • a revoked Jira connection updated on the same connection
  • Ran the CLI in a scratch sandbox: signed-out status, a masked set-secret, and a bad GitHub token rejected with the provider's 401, with no secret left on disk.

All 238 test cases in test/altimate/integrations.test.ts (grouped by describe block):

sameRecord (1)
  • a credential saved again, or changed in any field, is a different record
GitHub host policy (2)
  • a host setting names github.com only when it parses to github.com
  • an MCP server is confirmed for github.com only when nothing in it may name another host
detection parsing (3)
  • claude.json and .mcp.json servers
  • an MCP server env value counts as a credential only when it is one the provider reads
  • jira-cli config
status (3)
  • shape and states in demo mode
  • a signed-out user is not shown a linked workspace; mock mode keeps the demo one
  • not_found without detections
block policy and sync (1)
  • blocked providers stay local, unblocked sync
a block set while a mock sync runs (1)
  • stops the sync from being recorded
expiry (2)
  • isExpired uses a 60 second skew
  • status reports expired and expiresAt
keychain (9)
  • a secret goes to security on stdin, quoted, and never in argv
  • read and delete use the keychain by account
  • a slow keychain call does not block the event loop
  • a failed keychain delete is an error unless the item was already absent
  • a disconnect the keychain refuses keeps the record, so it can be retried
  • a keychain read is empty only when the item is missing; any other failure is an error
  • a keychain call that never answers is killed and reported, for reads and writes
  • a failed keychain write is an error
  • an account id outside the allowed characters is refused before security runs
state file (1)
  • is written for the owner only
state files that are not objects (1)
  • an array, null or scalar root is an error and is left as it was
secret storage (1)
  • a value with a line break is refused as not a token
workspace connections (71)
  • sync of a replaced detected token does not carry over the old token's expiry
  • sync does not upload into a connection that is already shared without --share
  • a failure after a shared rewrite that reaches the outer catch still says who has the new credential
  • a recorded leftover is removed even when the workspace marked its connection invalid
  • sync does not upload while the recorded workspace copy is on another sign-in
  • disconnect removes a leftover's secret fields too
  • a leftover's secret fields are removed even when a later save no longer lists them
  • a leftover whose workspace connection was deleted is kept and stops being a leftover
  • a leftover recorded for another backend is neither removed nor unmarked here
  • an attach-only sync never removes a local secret it did not record as a leftover
  • sync creates the managed connection, then updates it in place
  • a new connection the workspace marks invalid is removed again and nothing is stored
  • backend errors keep the message (code) format
  • status prefers the managed connection, else the latest validated own one, and skips shared ones
  • a newer hand-made connection stays what is shown while the deleted-elsewhere check follows the managed one
  • a synced credential deleted in the workspace is offered again when it is still found here
  • a synced record reports the managed connection's validity, whichever connection is shown
  • a synced record's expiry comes from the managed connection, not the one shown
  • sync --keep-synced takes the attach-only path that sync --all takes
  • a saved credential whose config cannot be collected fails that provider's sync with the reason, instead of stopping the run
  • sync to a shared workspace attaches nothing without --share and reports why; with it the outcome is marked shared
  • attach-only runs under the lock and names the kept workspace inert, with its id
  • sync over every provider leaves a saved connection alone and only attaches it
  • block still sets the policy when the workspace cannot be read, and says it was not checked
  • block refuses a provider whose managed connection is in the workspace
  • disconnect waits for a running upload instead of interleaving with it
  • sync only uploads a detected or registered credential, never a typed-in draft
  • sync moves a local credential to the workspace and leaves no secret here
  • a sync that lost the race to Keep local uploads nothing
  • a block that lands while an attach-only sync waits for the lock keeps the credential local and says why
  • a refusal of a record that was replaced while the provider was being asked does not mark the new record rejected
  • a link that cannot be looked up is reported, not read as not linked; without a login there is nothing to look up
  • a local cleanup that fails after the workspace accepted the connection is reported on a synced result
  • a record that cannot be written after the workspace accepted the upload is reported, and a retry updates the same connection
  • disconnect says when the connection could not be detached from the linked workspace
  • disconnect warns when it cannot tell whether the directory is linked, and not when it is unlinked
  • a synced record marked rejected locally is connected once the workspace shows the connection valid
  • sync over every provider leaves a workspace connection alone when this machine has no record of it
  • sync over every provider does not attach a workspace connection the workspace marks invalid
  • sync over every provider attaches a workspace connection when nothing for the provider is detected here
  • the status of a synced record takes the workspace connection's expiry on the real path
  • a synced record fixed in the workspace is attached by a run over every provider
  • a synced record takes its expiry from the workspace over an older local one
  • a sync prepared before a same-variant local update uploads nothing
  • a sync prepared before the record changed uploads nothing
  • sync records the provider check: validatedAt and account on success, rejected for a refused stored credential
  • sync uploads nothing when the provider rejects the detected credential, or cannot be reached
  • a synced connection carries the known expiry, so the workspace view shows it
  • sync over every provider says a synced connection deleted in the workspace is gone, not already there
  • sync over every provider attaches a workspace connection even when the only thing found here is a remote MCP server
  • a credential found here is still offered next to a hand-made workspace connection
  • purging a provider's secrets covers every variant, not only the connected one
  • purging a provider's secrets keeps the fields just written
  • a refused new connection that cannot be removed still reports the refusal
  • a fresh local connection wins over the remote one
  • disconnect deletes only the managed connections
  • a failed workspace delete keeps the local credential so disconnect can be retried
  • upsertManaged reports when the project is not linked to a workspace
  • workspace info reports an unlinked project
  • an already saved connection with no local secret is verified and reported as not linked
  • a saved connection that is gone from the workspace is still skipped
  • only the existing connections endpoints are called
  • the CLI exits non-zero on a failed sync, reports step outcomes, and refuses to block a synced connection
  • a hand-made connection is shown as not managed
  • a local expiry is not erased by a workspace copy of unknown expiry
  • without a signed-in backend nothing is removed
  • status says so when the workspace could not be read, instead of showing local states as current
  • a link remembered from earlier is not attached to or detached from
  • a state file that cannot be parsed is an error and is not replaced by an empty one
  • a secrets file that cannot be parsed is not replaced when another secret is stored
  • an unreadable Altimate login does not stop the local paths, but does stop removing a workspace copy
failure descriptions (3)
  • validation lists, string details and codes
  • a 404 does not claim a connection was missing, as it can come from a workspace or the catalog
  • a success whose body is not JSON is an error, not an empty list
backend answers that are not what they should be (3)
  • an empty answer or one without a connections list is an error, not no connections
  • a workspace answer that is not a record, or has no integrations list, is an error
  • a backend without the summary route is read from the workspace list, and only when the list carries the integrations
jira domain and cli flags (2)
  • normaliseJiraDomain sends the subdomain only
  • the browser sign-in flags are gone and the token command is removed
credentials flow › fields (6)
  • built-in table when nothing else is known
  • jira variant follows the site and the form is pre-filled
  • secrets report only a masked tail
  • jiraVariantFor
  • workspace catalog is read, cached and used when offline
  • parseCatalog reads a wrapped list and a variants map
credentials flow › set and set-secret (5)
  • a typed Jira site is reduced to the subdomain before it is stored
  • set stores a non-secret draft and rejects secrets and unknown fields
  • set-secret reads the injected clipboard and returns only the masked tail
  • clipboard content that is not a token is refused
  • secrets can come from an environment variable or stdin
credentials flow › where Jira values may come from (8)
  • jira-cli's Server setup gives its JIRA_API_TOKEN as the personal access token
  • a planted project file cannot point the user's token at another host
  • a token planted in a project file is not used
  • a project file still counts as present, without being syncable
  • a site from one source is not paired with a token from another
  • same-named servers in the user and project scopes are separate sources
  • a site and a token from the same source are used together
  • a site the user typed pairs with a detected token
credentials flow › validators (9)
  • github token: accepted and rejected
  • jira cloud: accepted and rejected
  • jira server: accepted and rejected
  • linear key: accepted and rejected
  • github reports the token expiry and an unreachable provider is not a rejection
  • a GitHub rate-limit 403 is not a rejected token and keeps the typed draft
  • a 403 without rate-limit signs is still a rejected token
  • a variant that matches nothing is an error, not the first variant
  • a plain-http Jira server URL is refused
credentials flow › connect and update (85)
  • missing fields are listed
  • local-only validates, stores locally and calls no backend
  • a 2xx without an account is not accepted as a valid credential
  • a catalog id naming the server variant gets the server type and token page
  • state writes are atomic and private
  • sync reads a detected Jira credential through the connect path
  • the gh token is read for github.com only, not the host GH_HOST names
  • a GitHub token that may belong to another host is never sent to api.github.com, from gh, the shell or an MCP server
  • a project's settings naming another host are not hidden by a parent's naming github.com
  • a rejected draft is removed only while it still holds the value that was checked
  • a successful connect keeps a draft entered again while it ran
  • a connected provider keeps its variant when a draft for the other variant is left
  • a successful connect keeps a non-secret value typed again while it ran
  • a recorded leftover is not offered again by connect
  • an official server's own token is read, not another token key beside it
  • Keep local remembers an old secret field it could not remove, so disconnect still removes it
  • a provider that redirects is not followed with the credential
  • Jira is detected from any token variable connect reads
  • a transport error that quotes the request does not print a credential
  • a config file whose args are not a list neither throws nor counts as GitHub's setup
  • Claude Code's config directory is where its servers and settings are read from
  • gh's active github.com login is found even when another stored account has expired
  • detected credentials are used without typing
  • a rejected token stores nothing
  • a rejected token does not linger to override what is detected
  • keep local on a connection that exists only in the workspace removes that copy and holds sync
  • update with local-only keeps a synced connection local instead of uploading
  • sync is held before the workspace copy is removed, and stays held when the removal fails
  • a draft that cannot be cleared on Keep local still removes the workspace copy, and says so
  • a record that cannot be written after the upload says the workspace has the connection, and connecting again updates it
  • an MCP env value that is only an unresolved reference does not count as a token
  • a sync whose cleanup fails records the uploaded credential's secret fields with the leftover
  • a leftover that cannot be recorded is not followed by advice to sync
  • Keep local over a recorded leftover writes nothing until the leftover mark is cleared
  • an update the workspace marks invalid keeps a recorded leftover marked, so sync still removes it
  • Keep local whose record write fails puts back the previous secrets and nothing old is purged
  • Keep local whose secret write fails puts back the leftover mark with the previous secrets
  • a local cleanup that fails after the upload is a warning on a connected result, and the record says synced
  • Keep local removes nothing from the workspace when the local copy cannot be stored
  • a local connect that fails part way restores the secrets it wrote
  • a catalog that omits the secret flags still treats the built-in secret fields as secret
  • a Jira variant naming the server is validated as the server
  • a refused replacement of a non-secret field leaves the working connection alone
  • keep local stores a credential unverified when the provider is unreachable; connect stores nothing
  • a connect whose record changed while the credential was being checked stores nothing
  • a connect prepared from an earlier credential is refused when the credential was saved again meanwhile
  • a local save whose old secrets cannot be purged is still saved, and says what is left
  • an offline re-save of the same stored token keeps its known expiry; a new token does not inherit it
  • a variant asked for by its exact id wins over one whose name contains it
  • a rejected input is not stored unverified
  • a failed state write leaves no temp file behind
  • two processes updating the same state never lose an update
  • discard clears typed fields and pasted secrets
  • sync creates the managed connection with the catalog field names and keeps no secret locally
  • jira server sends the variant type with its catalog fields
  • a new connection the workspace marks invalid is removed and nothing is stored
  • a replacement the workspace marks invalid leaves the connection marked rejected until update fixes it
  • a backend refusal is reported as message (code)
  • signed out, or blocked, behaves as local-only and says so
  • update needs a connection and keeps a local connection local
  • update of a synced connection updates the same connection in place
  • a credential kept local is never uploaded until sync is allowed
  • signed out, sync does not pretend to reach the workspace
  • keeping a synced connection local removes the workspace copy and holds sync
  • keeping a synced connection local while signed out changes nothing
  • a synced connection cannot be blocked: there is no local copy to keep
  • a remote-only managed connection can be updated
  • Keep local on a connection only the workspace holds refuses when the workspace cannot be read
  • Keep local on a connection only the workspace holds removes it and keeps the secret here
  • Keep local on a local record finds a workspace copy uploaded after it was recorded
  • a workspace refusal keeps typed non-secret values and drops secret drafts
  • a clipboard URL is not taken as a token
  • a failed upload keeps the local secret
  • a failed update of a credential the workspace holds says it is still synced
  • connect to a shared workspace attaches only with --share, and an update of an attached connection says it is shared
  • a connection shared outside any workspace is not rewritten without --share, and with it says so
  • a hand-made connection cannot be updated from here
  • a workspace connection removed elsewhere stops reading as synced
  • disconnect while signed out refuses when the credential is saved in the workspace
  • disconnect removes the recorded connection even after the host name changed, but only on its own backend
  • Keep local whose workspace removal fails keeps the recorded connection, so connecting again removes it
  • an update after the host name changed updates the recorded connection instead of adding another
  • a GitHub token named from the environment is refused beside another GitHub host
  • Keep local removes the recorded workspace copy after the host name changed
  • disconnect removes the credential secrets
credentials flow › rejected status (3)
  • a refused replacement leaves the working connection alone
  • a stored credential the provider now refuses is rejected until it is updated
  • a workspace connection marked invalid is rejected
credentials flow (1)
  • the CLI shows the credential commands and no browser flow
catalog fields a person fills in (1)
  • skips backend bookkeeping, repeated fields and browser sign-in variants
attachToIntegrations (2)
  • adds a missing entry with read-only tools only
  • sets the connection on an existing entry and extends a connection list
attach keeps another connection (7)
  • an entry on another connection keeps it, an empty one or this one is set
  • an entry on a connection that no longer exists takes this one
  • an entry on a connection shared by another member is kept; a deleted one is taken over, with its id dropped from the list
  • attach is an error when the workspace catalog has no entry for the provider
  • attach reports when the workspace kept its own connection
  • a workspace that is not private gets the connection only with --share, and says its members can use it
  • detach leaves an entry on another connection alone
collectConfig (1)
  • an optional secret with no stored value is left out; a required one is needed
detachFromIntegrations (1)
  • clears only this connection and leaves other entries alone
the CLI passes --share through and reports shared (1)
  • connect --share --json and sync --share
printed text and catalog shape (3)
  • clean removes escape sequences, control and bidi characters
  • the masked tail is dropped when it holds a control or direction character
  • catalogEntries unwraps a list, items, integrations and data alike
saved login (1)
  • a missing credentials file is signed out, an unreadable one is an error

Cost side effects

None. There are no model calls and no warehouse queries. Each command makes a fixed, small number of REST calls: to GitHub, Jira or Linear to validate a credential, and to the Altimate workspace API for connections and the integrations catalog. Nothing grows with user data.

Screenshots / recordings

Not applicable. This is a CLI change; the UI is in AltimateAI/altimate-claude-plugin#12.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an integrations CLI for GitHub, Jira, and Linear to check connection status, detect credentials, and connect or update accounts.
    • Added commands to sync, block, and disconnect provider connections, manage credential drafts, and open token pages.
    • Added options to save credentials locally or connect them to a workspace, with support for sharing connections.
    • Added credential validation and detection from supported tools and local configuration.
    • Added support for entering secrets from the clipboard, an environment variable, or standard input.
    • Added machine-readable JSON output for supported commands.

hkaltai and others added 6 commits October 28, 2026 09:11
Do not merge: experiment for evaluating direct altimate-code tools in Claude Code.

- Bring in `altimate-code mcp serve` and the workspace tools from the MCP draft branches
- `tool list|schema|run|context|daemon`: run the same adapter as `mcp serve` without a model
- `mcp serve` default set adds impact, lineage, PII, data-diff, equivalence and translation tools; `--all-tools` exposes the full allow-list
- Long-running per-project process keeps connections warm and releases DuckDB/SQLite file locks between calls
- `--connections` / `ALTIMATE_TOOL_CONNECTIONS`, `--args -` from stdin, `tool schema` for one tool
- DROP DATABASE, DROP SCHEMA and TRUNCATE stay blocked even with `--allow-write`
- `link --claude-md` writes CLI routing guidance for clients without MCP

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Do not merge: experiment.

- `tool list|schema|run|context|daemon` enable workspace tools automatically when the project is linked; `--no-workspace-tools` disables them
- `tool context` lists the linked workspace, its skills and how to use the workspace tools
- Daemon identity and spawn arguments follow the effective workspace-tools value

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ills

Do not merge: experiment.

- Every workspace skill sync also writes the skills into `<project>/.claude/skills/`, so linking or refreshing a project puts them on disk before a Claude Code session starts
- Copies follow the Claude Code plugin's rules: frontmatter reduced to `name` and `description`, command blocks neutralised, hook and plugin component paths skipped, user-written skills never touched, each copy marked and git-ignored
- Unlink and the feature-off path remove the copies; projects without `.claude` are left alone; `ALTIMATE_CLAUDE_SKILL_SYNC=0` disables it
- A mirror failure never changes the sync result
- Tests: `claude-skill-mirror.test.ts`, mirror wiring in `skill-sync.test.ts`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	packages/opencode/src/altimate/api/client.ts
…ll mirror

- daemon: release file locks when the last request finishes; serialize bind and
  stale-socket recovery with a lock; clients never unlink sockets; refuse a
  symlinked or foreign-owned socket directory
- mcp: warehouse_remove and driver installs need --allow-write over MCP too
- analyst effort: a per-model effort or thinking option wins over the default
- adapter: bound the answer_commit history kept across turns
- tool CLI: keep spilled results under the state directory, not /tmp
- skill mirror: skip a symlinked .claude or .claude/skills; swap copies without
  deleting the old one first
- docs: callers in one directory share the daemon

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Detects gh, jira-cli, env tokens and Claude MCP servers, syncs them to
the Altimate workspace or keeps them in the OS keychain, and connects a
provider through a browser consent flow with a loopback callback.
Expired tokens are re-created through the authorize flow; no refresh
token is stored. Disconnect also removes the workspace copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

The pull request adds Altimate backend operations and local credential and connection management for GitHub, Jira, and Linear. It adds integrations CLI commands for status, detection, connection management, and credential drafts.

Changes: Provider integrations

Layer / File(s) Summary
Backend contracts and operations
packages/opencode/src/altimate/integrations/backend.ts, packages/opencode/test/altimate/integrations.test.ts
Adds backend credential resolution, authenticated requests, connection and catalog operations, datamate retrieval and updates, and tests for response handling.
Local state and credential handling
packages/opencode/src/altimate/integrations/core.ts, packages/opencode/src/altimate/integrations/credentials.ts, packages/opencode/test/altimate/integrations.test.ts
Adds local state and secret storage, provider detection, catalog-based credential fields, credential resolution, draft handling, validation, and related tests.
Workspace status and policy
packages/opencode/src/altimate/integrations/core.ts, packages/opencode/test/altimate/integrations.test.ts
Adds local and remote status construction, merges managed workspace connections with local status, and adds provider blocking operations and tests.
Workspace connection lifecycle
packages/opencode/src/altimate/integrations/core.ts, packages/opencode/src/altimate/integrations/credentials.ts, packages/opencode/test/altimate/integrations.test.ts
Adds connection sync, attachment, sharing, local and workspace credential saves, secret cleanup, and managed connection removal. Tests cover these operations and failure cases.
Integrations CLI commands
packages/opencode/src/cli/cmd/integrations.ts, packages/opencode/src/index.ts, packages/opencode/test/altimate/integrations.test.ts
Adds integration subcommands and registers integrations as a top-level CLI command. Tests cover command behavior and output.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant IntegrationsCLI
  participant IntegrationsCredentials
  participant IntegrationsCore
  participant IntegrationsBackend
  IntegrationsCLI->>IntegrationsCredentials: Submit connection options
  IntegrationsCredentials->>IntegrationsCredentials: Validate provider credentials
  IntegrationsCredentials->>IntegrationsCore: Request workspace connection sync
  IntegrationsCore->>IntegrationsBackend: Create or update managed connection
  IntegrationsBackend-->>IntegrationsCore: Return connection result
  IntegrationsCore-->>IntegrationsCredentials: Return sync outcome
  IntegrationsCredentials-->>IntegrationsCLI: Return connection result
Loading
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat: altimate integrations command for GitHub, Jira and Linear" matches the main change. The PR adds the altimate integrations CLI command that connects, syncs, and manages GitHub, Jira,…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the template well. It has the issue section, type of change, a detailed 'What does this PR do?' section, verification steps, and a cost side-effects section. The 'Issue for thi…
Full details: Title check

Explanation

The title "feat: altimate integrations command for GitHub, Jira and Linear" matches the main change. The PR adds the altimate integrations CLI command that connects, syncs, and manages GitHub, Jira, and Linear credentials. The title is specific and follows a conventional commit style.

Full details: Description check

Explanation

The description follows the template well. It has the issue section, type of change, a detailed 'What does this PR do?' section, verification steps, and a cost side-effects section. The 'Issue for this PR' section has no linked issue, but the author explains why: the PR is stacked on #1609. Most sections are complete and specific, and the author marks the checklist. The main gap is that the description is very long and contains a large amount of detail. The template warns that clearly AI-generated descriptions may be ignored or closed, and the author's footer says 'Generated with Claude Code'. The description also has no 'Closes #' line. Those are minor points, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the fields in spring,
Then tucks each secret safe from sight.
GitHub, Jira, Linear join the ring,
Connections sync by day and night.
CLI commands guide the way,
And carrots mark the close of play.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 303b024f-fc1b-47c1-8677-71dd92f526fd
Commits

Reviewing files that changed from the base of the PR and between 35ba475 and 956b966.

Files selected for processing: 4

  • packages/opencode/src/altimate/integrations/core.ts
  • packages/opencode/src/altimate/integrations/credentials.ts
  • packages/opencode/src/cli/cmd/integrations.ts
  • packages/opencode/test/altimate/integrations.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@hkaltai
hkaltai changed the base branch from main to tool-cli-daemon October 29, 2026 14:56
@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

hkaltai and others added 16 commits October 30, 2026 09:25
…cking files

Files that reset the native dispatcher or mock the MCP SDK client modules now
restore them, so tests that run later in the same process see the real ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…space skill mirror

Copies carry a marker naming the skill, so a renamed copy is the user's; nested
CLAUDE.md files are not copied; staging uses an .altimate-staging- infix, gets
its .gitignore first and is swept when abandoned; an unreadable snapshot, or one
missing while it is swapped, leaves the copies alone; and the mirror and the
plugin's sync take turns under one mkdir lock in .claude/skills.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	packages/opencode/src/altimate/api/client.ts
#	packages/opencode/src/memory/store.ts
…uard read-only warehouse_add

- daemon: reload connections when a connections file changes, only when no other
  call is in flight, with calls arriving during a reload waiting for it; key the
  socket on the caller's ALTIMATE_CODE_CONN_* environment; resolve --connections
  once
- registry: validate a connections file before closing anything; never release
  in-memory DuckDB/SQLite connections
- mcp serve: release file database locks when no call is in flight
- warehouse_add: a read-only session cannot replace a connection named in the
  active registry, the global or project file, or the credential store
- adapter: bound the answer_commit history on every call, not only on commit
- skill mirror: keep copies when the snapshot or a skill cannot be read; let
  withdrawal run with ALTIMATE_CLAUDE_SKILL_SYNC=0
- tool CLI: decide the workspace tools default from the saved link, without a
  network call
- workspace-client: telemetry name and disabled-workspace stub
- docs and help text for the daemon, workspace tools and --all-tools

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nder concurrent and partial reads

The mkdir lock shared with the plugin is renewed by its holder, taken over from
a dead one by rename, released only by the holder (an empty token directory),
and never waited on past its deadline; a holder that lost it stops before the
next swap. The manifest is read without following symlinks and re-read before
the removal pass; a listed skill directory that is gone, or credentials that
exist but cannot be read, change nothing. One skill's failed swap no longer
stops the others; tree comparison streams one file pair at a time; frontmatter
whitespace matches Python's; readManifest rejects a skills array.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
connect now asks for the same fields as the workspace web form, read
from the integrations catalog, pre-filled from credentials found on the
machine. Secrets come from detection, the clipboard, an env var or
stdin and are never printed. Credentials are validated directly with
GitHub, Jira or Linear, then kept in the keychain or synced to the
workspace. A rejected token can be updated on the same connection.
The browser OAuth flow moves behind connect --oauth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and withdraw them on sign-out

Each copy is swapped in only while the lock is held and the snapshot is the one
read and still the signed-in account's, so a mid-copy swap, takeover or sign-out
publishes nothing. Swap detection uses the staging directory's mtime, which a
rename updates on every platform. A SKILL.md that is not a regular file skips
that skill instead of freezing every sync; markers decode strictly with their BOM
kept, as the plugin's Python reads them. The sync waits at most 2 s for the lock.
Signing out withdraws the project's copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Saving, updating, listing and removing a workspace connection now use
the existing /connections endpoints, so no backend change is needed.
The browser OAuth flow is removed; credentials are always the
workspace's own fields, validated with the provider first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts check and its read

The plugin's copy treats that as a snapshot changing underneath and changes nothing;
the mirror dropped the skill instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Saving a GitHub, Jira or Linear credential (connect, update or sync) now
also attaches the connection to the project's linked workspace, so it shows
on the workspace's integrations. A new entry enables only read-only tools.
Sync re-attaches a connection already saved to the account when no local
secret is kept. A workspace the caller does not own is reported clearly.

The workspace commands honour ALTIMATE_API_URL, ALTIMATE_TENANT and
ALTIMATE_TOKEN like the integrations client, so a local backend works end
to end, and sync/status report the real tenant and workspace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… every copy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
status and sync --json now include `linked` and the linked workspace `id`,
so clients can offer to link an unlinked project instead of showing the
tenant name as if it were a workspace. The human header says when the
project is not linked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e tools

- `daemon`: requests wait for an in-progress file release, `stop` replies
  before shutting down, and the daemon key includes
  `ALTIMATE_DISABLE_SCHEMA_VALUES`, `ALTIMATE_INTEGRATIONS` and
  `ALTIMATE_DISABLE_WORKSPACE`.
- `permissions`: the blocked-statement check runs before the read-permission
  shortcut.
- `claude-md`: a symlinked `CLAUDE.md` is left untouched.
- `workspace-tools`: workspace-authored names and descriptions render as one
  inert line, skills are read through `WorkspaceClient.readSkill`, and the
  workspace is labelled with `workspaceLabel`.
- MCP workspace adapter: an adapter is closed only after the operations
  using it finish; `serverInstructions` releases file connections it opened.
- `outputLimits` reads organisation-managed config and preferences.
- `schema-list`: MySQL and Redshift (whose drivers ignore binds) get an
  escaped schema literal; schema names are sorted before the limit.
- `registry.releaseFileConnections` keeps remote and in-memory URI stores.
- `sql_execute` batches: `truncated` reports row-limited or clipped items,
  references resolve against the default warehouse, duplicate labels are
  rejected, backslashes are escaped for BigQuery, Snowflake, Databricks and
  ClickHouse, and an unmaterialized spill returns no table.
- `answer_commit`: integers keep every digit; coverage and number checks
  stand down when the run budget is ending (one shared `budgetEnding`).
- `warehouse_add` resolves relative store paths against the project root;
  `warehouse_list` skips only workspace-routed connections in discovery.
- `analyst-effort` honours SAP `modelParams` and the configured
  `model.variants`.
- Workspace client: `readSkill` opens with `O_NOFOLLOW`; context lists only
  skills with a regular `SKILL.md`. `releaseLocalSession` clears every
  per-session map; skill withdrawal runs in `finally` on purge.
- MongoDB `listTables` checks that an empty database exists.
- Docs and `--allow-write` help match the actual policies.
- Tests for each behaviour change; new suites restore their spies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ferences

BigQuery and Spark/Databricks have no `''` escape inside a string literal
(Databricks reads `'it''s'` as two adjacent literals, `its`). Batch
references now escape the quote with a backslash for those two dialects
and keep `''` for the rest. The read-only check does not lex their
backslash escape, so such a step is refused instead of running with a
wrong value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rules; address review findings

- data_diff refuses any source, target or where_clause that is not one complete read-only
  query (classifier read, single statement, balanced parentheses, no side-effect or dynamic
  query() calls) before connecting, checks every statement it runs, and opens every
  connector read-only. sql_check keeps its stricter rules (shared read-only-sql helper).
- isBlockedStatement classifies the whole pattern, so leading comments and multi-statement
  patterns stay hard-blocked.
- Redshift values in batch references get their backslashes escaped.
- Tool daemon: the idle timer waits for a pending file release; only a request that ran a
  tool leads to a release, and a stop is answered without waiting for one; the socket is
  owner-only.
- Workspace: refresh clears the active adapter before closing it; a snapshot removed
  mid-read lists no skills; copies into .claude/skills are opt-in with
  ALTIMATE_CLAUDE_SKILL_SYNC=1 (the Claude Code plugin sets it).
- Analyst effort ignores non-object model params and output_config without effort; managed
  output preferences resolve files against their own directory; warehouse_add shares the
  registry's project root; mcp --allow-write help names the hard blocks.
- Docs for warehouse_add's local writes, Claude Code skill copies, analyst effort and
  answer_commit; tests for each change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hkaltai and others added 10 commits November 17, 2026 12:57
…code configs count when deciding who may use the shell token, and a recorded connection id is used only on the backend it was recorded for

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r GH_TOKEN, and gh is asked for its own github.com login without them, so a token for another host cannot reach api.github.com

A token in those variables may be for any host, and every attempt to tell which from the surrounding MCP and settings files left another place unread. GitHub tokens now come only from gh's stored github.com login, GitHub's official MCP setups, or a token entered here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…emoved, so a failed removal can be retried, and detection reads Claude Code's config from CLAUDE_CONFIG_DIR

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd MCP args that are not a list never crash detection

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…another Altimate sign-in, and gh's active github.com login is found even beside an expired account

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s program, every save refuses while the copy is on another sign-in, disconnect needs a sign-in for a recorded copy, and a leftover remembers its secret fields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… is on another sign-in, and leftover field handling is pinned on both paths

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tatus say a connection is on another sign-in instead of calling it removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… view

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

1 similar comment
@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@hkaltai

hkaltai commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Ready for re-review at 8bc60b8e5f. Every round-4 thread has a reply, and so do all bot threads.

  • GitHub sources: the round-4 majors came from guessing which host a shell token belongs to, and every guess left another config location unread. So the shell's GITHUB_TOKEN/GH_TOKEN are no longer read for GitHub. gh is asked only for its own stored github.com login: it runs without the token and host variables and with --hostname github.com. MCP tokens are read only from GitHub's official setups, word for word. A token found only in the shell is entered once with connect github; this is in Known limitations.
  • Leftovers: a leftover is removed only when it was recorded as one, for the backend it was recorded for and with the fields it had. The retry sync never uploads it. Keep local can't lose it, and a sync that read it before it was marked is refused.
  • Another sign-in: each connection id is recorded with its backend. Every command refuses, changing nothing, while the recorded workspace copy is on another Altimate sign-in.
  • Checks: the integrations suite passes 227 of 227. The whole PR went through repeated two-engine adversarial gates with mutation checks on every guard. Codex's credits ran out for the last two rounds, so the final gate is Claude's PASS alone.

@hkaltai
hkaltai requested a review from sahrizvi November 17, 2026 11:46
throw new Error(`${PROVIDER_NAMES[id]} is saved in your workspace. Sign in to Altimate to remove it, then disconnect again.`)
// Nothing is forgotten here while its workspace copy sits on a backend this login cannot reach.
const elsewhere = recordedElsewhere(id, login)
if (elsewhere) throw new Error(elsewhere)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: A recorded backend key that cannot be reproduced leaves the local credential undeletable

recordedElsewhere only clears when backendKey(cfg) matches the stored connectionBackend exactly (apiUrl#tenant). If that key can never come back — the tenant/org was renamed or deleted, or the record was written while ALTIMATE_INTEGRATIONS_API_URL/ALTIMATE_INTEGRATIONS_TENANT were set and that override is now gone — this throws, connect refuses at credentials.ts:780 and :884, and sync refuses at core.ts:1203 and :1248. The secret then stays on disk with no CLI path to remove it (only hand-editing integrations.json), while block does not delete secrets either. Consider letting disconnect fall back to the local purge when the recorded copy cannot be reached (or an explicit override), so a stale key is not a dead end.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6a68750. disconnect <provider> --local-only removes the credential from this machine only and makes no workspace call, so a recorded sign-in that can never come back is not a dead end. The "another Altimate sign-in" refusal now names it. There's a test for it, and the CLI help lists the flag.

const own = backend.ownConnections(visible)
// The workspace decides whether the connection is usable, not the flag kept here from an earlier check.
// A recorded id names a connection only on the backend it was recorded for.
const sameBackend = (store.providers[id]?.connectionBackend ?? backendKey(cfg)) === backendKey(cfg)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: sameBackend duplicates recordedElsewhere

When known != null, knownFor (line 1187) has already established connectionId != null, and both loadStore() reads happen back-to-back with no await between them, so sameBackend === false implies recordedElsewhere(...) is non-null and line 1203 has already returned. The : undefined branch of the ternary at line 1204 is therefore unreachable, and two checks derive the same backend comparison from two separate store reads. Dropping sameBackend and always using own.find((c) => c.id === known && c.integration_id === INTEGRATION_IDS[id]) keeps the behavior identical.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 6a68750. sameBackend is dropped. recordedElsewhere already returns before that point whenever the backends differ, so the lookup by recorded id is unconditional.

* written, that the leftover is not recorded.
*/
/** Which backend and tenant a connection id belongs to: the same id elsewhere is another connection. */
/** Why a workspace copy cannot be removed from the backend signed in to: it was recorded on another one. Null when it can. */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: The doc comments no longer sit on the functions they describe

Inserting recordedElsewhere left the neighbouring blocks where they were: the recordLeftover doc at lines 960-964 now documents recordedElsewhere, the backendKey one-liner at line 965 is orphaned above it, and backendKey at line 973 has no doc at all. Move line 965 down to 973 and lines 960-964 down to 975.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 6a68750. The recordedElsewhere, backendKey and recordLeftover doc comments now sit on their own functions.

hkaltai and others added 11 commits November 17, 2026 21:00
…gn-in can't come back, and the cross-sign-in check and doc comments are tidied

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…P server's own token key is the only one read, Keep local remembers old fields it could not remove, and the repository-file note points at connect

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…amed from the environment is refused beside another host, and an update after a host name change updates the recorded connection

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and a save keeps a draft entered again while it ran

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oves only the drafts it used while unchanged, and a connection the user renamed keeps its name

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… cut at a control character, and this tool's recorded connection is found before the name in status and every lookup

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pt only their own GitHub program, only exact generated names are renamed, and jira-cli's bearer setup supplies the personal access token

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…token page, and the jira-cli bearer token is pinned as not a Cloud token

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a redirect with a credential, and Jira is detected from every token variable connect reads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

1 similar comment
@github-actions

Copy link
Copy Markdown

👋 This PR was automatically closed by our quality checks.

Common reasons:

  • New GitHub account with limited contribution history
  • PR description doesn't meet our guidelines
  • Contribution appears to be AI-generated without meaningful review

If you believe this was a mistake, please open an issue explaining your intended contribution and a maintainer will help you.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 5 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/opencode/test/altimate/integrations.test.ts">

<violation number="1">
P2: This test covers only `JIRA_PAT_TOKEN`, not “any token variable” supported by detection. Exercise every supported variable, or parameterize the case, so regressions in the other detection sources are caught.</violation>

<violation number="2">
P2: This second connect's result is discarded, so the test passes even if the retained cloud-variant connect fails. Assert that the call returns `status: "connected"` before checking the variant.</violation>
</file>

<file name="packages/opencode/src/altimate/integrations/core.ts">

<violation number="1" location="packages/opencode/src/altimate/integrations/core.ts:1335">
P2: In mock/demo mode, `disconnectLocal` also removes the simulated workspace connection, so `disconnect --local-only` does not leave the workspace copy intact. Preserve the mock remote in this branch; local-only must clear only machine credentials.</violation>
</file>

<file name="packages/opencode/src/altimate/integrations/backend.ts">

<violation number="1" location="packages/opencode/src/altimate/integrations/backend.ts:45">
P1: `redactSecrets` skips credentials shorter than six characters, but `backendConfig` accepts any non-empty backend token. A short token can therefore be echoed by a transport error; redact the complete secret regardless of length and apply any minimum only to incidental fragments.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

* character (Bun's invalid-header error does), so each such piece is taken out as well as the whole value.
*/
export function redactSecrets(text: string, secrets: string[]): string {
const pieces = secrets.flatMap((v) => [v, v.trim(), ...v.split(/[\s\x00-\x1f]+/)]).filter((v) => v.length >= 6)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: redactSecrets skips credentials shorter than six characters, but backendConfig accepts any non-empty backend token. A short token can therefore be echoed by a transport error; redact the complete secret regardless of length and apply any minimum only to incidental fragments.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/altimate/integrations/backend.ts, line 45:

<comment>`redactSecrets` skips credentials shorter than six characters, but `backendConfig` accepts any non-empty backend token. A short token can therefore be echoed by a transport error; redact the complete secret regardless of length and apply any minimum only to incidental fragments.</comment>

<file context>
@@ -37,6 +37,15 @@ export interface Connection {
+ * character (Bun's invalid-header error does), so each such piece is taken out as well as the whole value.
+ */
+export function redactSecrets(text: string, secrets: string[]): string {
+  const pieces = secrets.flatMap((v) => [v, v.trim(), ...v.split(/[\s\x00-\x1f]+/)]).filter((v) => v.length >= 6)
+  return [...new Set(pieces)].sort((a, b) => b.length - a.length).reduce((m, v) => m.split(v).join("<redacted>"), text)
+}
</file context>
Suggested change
const pieces = secrets.flatMap((v) => [v, v.trim(), ...v.split(/[\s\x00-\x1f]+/)]).filter((v) => v.length >= 6)
const pieces = secrets.flatMap((v) => [v, v.trim(), ...v.split(/[\s\x00-\x1f]+/)]).filter(Boolean)

@@ -0,0 +1,3658 @@
import { afterAll, afterEach, describe, expect, spyOn, test, beforeEach } from "bun:test"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This test covers only JIRA_PAT_TOKEN, not “any token variable” supported by detection. Exercise every supported variable, or parameterize the case, so regressions in the other detection sources are caught.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/test/altimate/integrations.test.ts, line 2237:

<comment>This test covers only `JIRA_PAT_TOKEN`, not “any token variable” supported by detection. Exercise every supported variable, or parameterize the case, so regressions in the other detection sources are caught.</comment>

<file context>
@@ -2121,6 +2192,79 @@ describe("credentials flow", () => {
+    })
+
+    test("Jira is detected from any token variable connect reads", () => {
+      process.env.JIRA_PAT_TOKEN = GOOD
+      try {
+        expect(core.scan().find((d) => d.id === "jira")?.source).toEqual({ kind: "env", label: "JIRA_PAT_TOKEN" })
</file context>

@@ -0,0 +1,3658 @@
import { afterAll, afterEach, describe, expect, spyOn, test, beforeEach } from "bun:test"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This second connect's result is discarded, so the test passes even if the retained cloud-variant connect fails. Assert that the call returns status: "connected" before checking the variant.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/test/altimate/integrations.test.ts, line 2166:

<comment>This second connect's result is discarded, so the test passes even if the retained cloud-variant connect fails. Assert that the call returns `status: "connected"` before checking the variant.</comment>

<file context>
@@ -2112,6 +2132,57 @@ describe("credentials flow", () => {
+      expect((await creds.connectCredentials({ id: "jira", variant: "cloud", localOnly: true })).status).toBe("connected")
+      await creds.setDraft("jira", "jiraBaseUrl", "https://jira.corp.example")
+      await token("jira", "jiraApiToken")
+      await creds.connectCredentials({ id: "jira", localOnly: true })
+      expect(core.loadStore().providers.jira?.variant).toBe("cloud")
+      // fields and the token page follow the same variant as connect.
</file context>
Suggested change
import { afterAll, afterEach, describe, expect, spyOn, test, beforeEach } from "bun:test"
expect((await creds.connectCredentials({ id: "jira", localOnly: true })).status).toBe("connected")

return withLock(async () => {
// Asked for explicitly: the workspace copy, wherever it is, is left alone and only this machine is cleared.
if (opts.localOnly) {
const removedLocal = await disconnectLocal(id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: In mock/demo mode, disconnectLocal also removes the simulated workspace connection, so disconnect --local-only does not leave the workspace copy intact. Preserve the mock remote in this branch; local-only must clear only machine credentials.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/opencode/src/altimate/integrations/core.ts, line 1335:

<comment>In mock/demo mode, `disconnectLocal` also removes the simulated workspace connection, so `disconnect --local-only` does not leave the workspace copy intact. Preserve the mock remote in this branch; local-only must clear only machine credentials.</comment>

<file context>
@@ -1303,9 +1326,16 @@ export interface DisconnectResult {
   return withLock(async () => {
+    // Asked for explicitly: the workspace copy, wherever it is, is left alone and only this machine is cleared.
+    if (opts.localOnly) {
+      const removedLocal = await disconnectLocal(id)
+      await creds.discardDraftSecrets(id)
+      return { removedLocal, removedRemote: 0, detached: true }
</file context>

const validatedAt = (c: backend.Connection) => Date.parse(c.last_validated_at ?? "") || 0

/** The connection this tool manages for a provider: matched on integration and name. */
/** This tool's connection for a provider: the one recorded on this backend first (it may have been renamed), else the one named for this machine. */

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SUGGESTION]: Duplicate doc block for findManaged

Line 595 still carries the old /** The connection this tool manages for a provider: matched on integration and name. */, and this new block repeats it. The new text also says "the one recorded on this backend first", which only holds when the caller passes recorded; otherwise the match is by name. Delete the line 595 comment and document the recorded parameter in the remaining one.

// The connection this machine recorded on this backend comes first, so a changed host name updates it instead of adding another.
const own = backend.ownConnections(visible)
const rec = loadStore().providers[id]
const recorded = rec?.connectionId != null && rec.connectionBackend === backendKey(cfg) ? own.find((c) => c.id === rec.connectionId && c.integration_id === INTEGRATION_IDS[id]) : undefined

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SUGGESTION]: The recorded-connection lookup is duplicated

findManaged now takes the recorded id, and recordedIds(cfg) builds exactly this per-provider map for the current backend (used by statusRemote and managedInWorkspace), yet this block re-implements the condition inline and removeManaged does it a third time at line 1403. Replacing lines 1017-1018 with const existing = findManaged(own, id, os.hostname(), rec?.connectionBackend === backendKey(cfg) ? (rec.connectionId ?? null) : null) keeps the recorded-first rule in one place.

if (opts.localOnly) {
const removedLocal = await disconnectLocal(id)
await creds.discardDraftSecrets(id)
return { removedLocal, removedRemote: 0, detached: true }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SUGGESTION]: --local-only still removes the mock workspace copy

disconnectLocal ends with removeMockRemote(id) (line 1370), so in mock/demo mode this branch deletes the simulated workspace connection, while it reports removedRemote: 0 and the CLI prints "any workspace copy was left in place". This branch needs a local-only clear that leaves the mock workspace stand-in alone, e.g. by splitting the local purge from the mock-remote removal.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants